<?php
session_start();
(substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))?ob_start('ob_gzhandler'):ob_start();
header('Content-type: text/html; charset=utf-8');

require_once('../config.php');
require_once('autoload.php');

/****check session*****/
$user_id = isset($_SESSION['ID'])?$_SESSION['ID']:'';
if($user_id == ''){
    header('Location:'.URL_BASE);
}
/*Load all router*/
$rt = new handle_route();
$view = new system_view();
$_seokey = $rt->rt_get_all_val_seo();
require_once('process.php');
/*Load controller*/

switch($comCur)
{
    case 'com':
        require_once($path . 'lang/com_lang.php');
        require_once($path . 'com.php');
        $com = new com_intall();
        $com->user_id = $user_id;
        if(empty($com->layout))
        {
            $html = $com->index_controller();
            $html = $view->view_assign($html, $_);  
            
        }else{
            
            print( $com->index_controller() ); exit();
        }
        
    break;
    
    case 'model':
        require_once($path . 'lang/model_lang.php');
        require_once($path . 'model.php');
        $model = new model_intall();
        if(empty($model->layout))
        {
            $html = $model->index_controller();
            $html = $view->view_assign($html, $_);  
            
        }else{
            print( $model->index_controller() ); exit();
        }
    break;
    
    case 'action':
        require_once($path . 'lang/action_lang.php');
        require_once($path . 'action.php');
        $action = new action_intall();
        $html = $action->index_controller();
        if(empty($action->layout))
        {
            $html = $view->view_assign($html, $_);     
        }else{
            print( $action->index_controller() ); exit();
        }
    break;
    
    case 'module':
        require_once($path . 'lang/module_lang.php');
        require_once($path . 'module.php');
        $action = new module_intall();
        $html = $action->index_controller();
        if(empty($action->layout))
        {
            $html = $view->view_assign($html, $_);     
        }else{
            print( $action->index_controller() ); exit();
        }
    break;
    
    case 'update_action':
        require_once($path . 'lang/update_action.php');
        require_once($path . 'update_action.php');
        $action = new update_action();
        $html = $action->index_controller();
        if(empty($action->layout))
        {
            $html = $view->view_assign($html, $_);     
        }else{
            print( $action->index_controller() ); exit();
        }
    break;
    
    case 'update_permission':
        require_once($path . 'update_permission.php');
        $action = new update_permission();
        $html = $action->index_controller();
        if(empty($action->layout))
        {
            $html = $view->view_assign($html, $_);     
        }else{
            print( $action->index_controller() ); exit();
        }
    break;
    
    default:
        require_once($path . 'lang/index_lang.php');
        require_once($path . 'index.php');
        $index = new index_intall();
        $html = $view->view_assign($index->index_controller(), $_);
}
$_['url_base'] = URL_BASE;
$_['content'] = $html;
$_['base_install'] = URL_BASE . 'installs';
$_['base_home'] = URL_BASE;
$_['base_admin'] = URL_BASE . 'admin';
if(!is_array($html)){
    $shtml = file_get_contents('theme/index.phtml');
    $shtml = $view->view_assign($shtml, $_);
}else{
    $shtml = implode($html);
}
print($shtml);

